﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chefbook.HelperMethods;
using NUnit.Framework;

namespace UnitTests.HelperMethodsTests
{
    [TestFixture]
    public class ParameterValidationFixture
    {
        [Test]
        public void ThrowIfNullTest1()
        {
            object a = null;
            Assert.Throws<ArgumentNullException>(() => a.ThrowIfNull("a"));
        }

        [Test]
        public void ThrowIfNullTest2()
        {
            object a = new object();
            object b = null;
            Assert.DoesNotThrow(() => b = a.ThrowIfNull("a"));
            Assert.AreEqual(a, b, "ThrowIfNull didn't return the value when it wasn't null");
        }

        [Test]
        public void ValidateArgument1()
        {
            string test = "Testing";
            Assert.Throws<ArgumentException>(
                () => ParameterValidation.ValidateArgument(
                    () => test.Length == 3, "test"));
        }
        [Test]
        public void ValidateArgument2()
        {
            string test = "Testing";
            Assert.DoesNotThrow(
                () => ParameterValidation.ValidateArgument(
                    () => test.Length == 7, "test"));
        }

    }
}
